package cn.stylefeng.guns.modular.business.job;

import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description: 从配置文件加载任务信息
 * @Author: lxc
 * @Date: Created in 2018/12/17
 */

@Component
@PropertySource(value = "classpath:application.yml")
public class ScheduledTask {

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(fixedDelayString = "2000")
    public void getTask1(){
        System.out.println("【任务1,从配置文件加载任务信息，当前时间：】" + dateFormat.format(new Date()));
    }

    @Scheduled(cron = "${cron}")
    public void getTask2(){
        System.out.println("【任务2,从配置文件加载任务信息，当前时间：】" + dateFormat.format(new Date()));
    }

}
